<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <link rel="stylesheet" href="/aaa/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/aaa/layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">操作员</label>
                    <div class="layui-input-block">
                        <input type="text" name="tas-name" id="tas-name" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">学生证号</label>
                    <div class="layui-input-block">
                        <input type="text" name="tas-stcard" id="tas-stcard" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">所属学校</label>
                </div>
                <div class="layui-inline" style="margin-left: -120px;">
                    <div class="layui-input-block">
                        <select name="tas-school" id="tas-school" lay-search=""
                                 lay-filter="tas-school">

                        </select>
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">是否认证</label>
                </div>
                <div class="layui-inline" style="margin-left: -120px;">
                    <div class="layui-input-block">
                        <select name="approveState" id="tas-approveState">
                            <option value="">全部</option>
                            <option value="0">未认证</option>
                            <option value="1">已认证</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <button id="tas-searchbtn" class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="LAY-user-back-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </div>

<div class="layui-card-body">
    <table class="layui-hide" id="toapprovesttbl" lay-filter="toapprovesttbl-filter"></table>
    <script type="text/html" id="studentapprove-bar">
        <a class="layui-btn layui-btn-xs" lay-event="studentapprove-sure">认证</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="studentapprove-del">取消</a>
    </script>
</div>
    </div>
</div>

<!--操作人员 自动获取模板-->
<script type="text/html" id="tas-employeeinfo">
    <option></option>
    {{#  layui.each(d, function(index, item){ }}
    <option value="{{item.schoolId}}">{{item.school}}</option>
    {{#  }); }}
</script>
<script src="/aaa/layuiadmin/layui/layui.js"></script>
<script th:inline="none">
    layui.use(['table','form'], function(){
        var table = layui.table;
        var $ = layui.$;
        var laytpl=layui.laytpl;
        var form =layui.form;
        //操作员工自动加载
        $.ajax(
            {
                type : "post",
                url : "/aaa/studentapprove/getSchoolName", //接口路径
                dataType : "json",
                async : false,
                success : function(data) {

                    var demo = $('#tas-employeeinfo');
                    var getTpl = demo.html(),
                        view = $('#tas-school');
                    laytpl(getTpl).render(data, function(html) {

                        view.html(html);
                    });
                    form.render();
                },
                error : function(result, status) {}
            });

        table.render({
            elem: '#toapprovesttbl'
            ,height: 312
            ,url: '/aaa/studentapprove/getAllStudentApprove' //数据接口
            ,page: true //开启分页
            ,cols: [
                [
                    {field: 'telephone', title: '学生电话',align:'center'}
                    ,{field: 'name', title: '学生姓名', align:'center'}
                    ,{field: 'username', title: '昵称',align:'center'}
                    ,{field: 'school', title: '学校姓名',align:'center'}
                    ,{field: 'stcard', title: '学生证号',align:'center'}
                    ,{field: 'entrancedate', title: '入学时间',align:'center'}
                    ,{field: 'graduatedate', title: '毕业时间',align:'center'}
                    ,{field: 'stcardPhotoUrl', title: '学生证照片',align:'center' ,templet: function(d){
                        return '<img src="'+d.stcardPhotoUrl+'" />'
                    }
                },{field: 'approveState', title: '认证状态',align:'center' ,sort:true,templet: function(d){
                        if(d.approveState==0){
                            return '<span style="color: #c00;">未认证</span>'
                        }else{
                            return '<span style="color: green;">已认证</span>'
                        }
                    }
                },{field: 'ename', title: '认证人',align:'center'}
                    ,{field:'yyy', title: '操作', width: 200, toolbar: '#studentapprove-bar', align:'center'}
                ]
            ],
            //显示大图-----------------------------------------------------------------------------------------------
            done:function(res,curr,count){
                hoverOpenImg();//显示大图
                $('table tr').on('click',function(){
                    $('table tr').css('background','');
                    $(this).css('background','<%=PropKit.use("config.properties").get("table_color")%>');
                });
            }

        });


        //显示大图-----------------------------------------------------------------------------------------------
        function hoverOpenImg(){
            var img_show = null; // tips提示
            $('td img').hover(function(){
                var kd=$(this).width();
                kd1=kd*3;          //图片放大倍数
                kd2=kd*3+30;       //图片放大倍数
                var img = "<img class='img_msg' src='"+$(this).attr('src')+"' style='width:"+kd1+"px;' />";
                img_show = layer.tips(img, this,{
                    tips:[2, 'rgba(41,41,41,.5)']
                    ,area: [kd2+'px']
                });
            },function(){
                layer.close(img_show);
            });
            $('td img').attr('style','max-width:70px;display:block!important');
        }

        $('#tas-searchbtn').click(function () {
            table.reload('toapprovesttbl', {
                url: '/aaa/studentapprove/getAllStudentApprove',
                where: {
                    name:$("#tas-name").val(),
                    stcard:$("#tas-stcard").val(),
                    approveState:$("#tas-approveState").val(),
                    schoolId:$("#tas-school").val()
                } //设定异步数据接口的额外参数
                //,height: 300
            });
        });

        /*点击认证按钮发送请求改变状态信息等*/
        table.on('tool(toapprovesttbl-filter)', function(obj){
            var data = obj.data;
            if(obj.event === 'studentapprove-sure'){
                if(!data.approveState){
                    layer.confirm('确定认证么？', function(index){
                        $.post({
                            url:'/aaa/studentapprove/studentapprovePass',
                            data:{
                                telephone:data.telephone
                            },
                        },function (data) {
                            if(data.code>0){
                                layer.msg('认证通过');
                            }else{
                                layer.msg('认证失败,请重试');
                            }
                            layer.close(index);
                            table.reload('toapprovesttbl');

                        })
                    });
                }else{
                    layer.msg('该消息已认证通过,不能再次认证');
                }
            } else if(obj.event === 'studentapprove-del'){
                if(!data.approveState){
                    layer.confirm('确定取消认证么？', function(index){
                        $.post({
                            url:'/aaa/studentapprove/delStudentApprove',
                            data:{
                                telephone:data.telephone
                            },
                        },function (data) {
                            if(data.code>0){
                                layer.msg('取消成功');
                            }else{
                                layer.msg('取消失败,请重试');
                            }
                            layer.close(index);
                            table.reload('toapprovesttbl');

                        })
                    });
                }else{
                    layer.msg('该消息已认证通过,不能被删除');
                }

            };
        });

    });



</script>



</body>
</html>
